<template>
  <div class="resume_manage">
    <div class="info">
      <el-form class="demo-ruleForm"
        style="margin-top: 20px; padding: 1px 30px; border-bottom: 1px solid rgba(232,232,232,1);" ref="form"
        :rules="rules" :model="conditions">
        <div class="d-flex" style="margin-top: 10px;">
          <el-row>
            <el-col :span="8">
              <el-form-item label="公司名称" prop="nature" ::span="8" class="wid_input d-flex">
                <el-input v-model="conditions.company" placeholder="公司名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="简历状态" prop="industry" ::span="8" class="wid_input d-flex">
                <el-select v-model="conditions.status" filterable placeholder="简历状态">
                  <!--1.已投递，2.被查看，3.有意向，4.邀请面试，5.不合适-->
                  <el-option v-for="(value,key) in resumeStatusMap" :key="key" :label="value" :value="key"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="现从事行业" prop="trade" class="wid_input d-flex">
                <el-cascader :options="options.tradeCategory" :props="{value:'code',label:'name',children:'childVo'}"
                  v-model="conditions.trade"></el-cascader>
                <!-- <el-select
                                    v-model="conditions.trade"
                                    filterable
                                    placeholder="现从事行业"
                                    style="width: 267px;"
                                >
                                    <el-option
                                        v-for="item in options.tradeCategory"
                                        :key="item.code"
                                        :label="item.name"
                                        :value="item.code"
                                    ></el-option>
                                </el-select>-->
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <div class="d-flex">
          <el-row>
            <el-col :span="8" class="d-flex">
              <el-form-item label="年龄" prop="nature" class="mini_input d-flex left_box">
                <!-- <el-input-number
                                    v-model="conditions.startAge"
                                    :min="1"
                                    :max="conditions.endAge"
                                    label="起始年龄"
                                ></el-input-number>-->
                <el-select v-model="conditions.startAge" filterable placeholder="请选择">
                  <el-option v-for="item in 45" :key="item" :value="item+15"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="-" prop="endAge" class="mini_input right_box d-flex">
                <el-select v-model="conditions.endAge" filterable placeholder="请选择">
                  <el-option v-for="item in 45" :key="item" :value="item+15"></el-option>
                </el-select>
                <!-- <el-input-number
                                    v-model="conditions.endAge"
                                    :min="conditions.startAge"
                                    :max="100"
                                    label="截止年龄"
                                ></el-input-number>-->
              </el-form-item>
            </el-col>
            <el-col :span="8" class="d-flex">
              <el-form-item label="学历" prop="nature" class="mini_input d-flex left_box">
                <el-select v-model="conditions.startEducation" filterable placeholder="请选择">
                  <el-option v-for="item in options.education" :key="item.val" :label="item.name" :value="item.val">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="-" prop="nature" class="mini_input right_box d-flex">
                <el-select v-model="conditions.endEducation" filterable placeholder="请选择">
                  <el-option v-for="item in options.education" :key="item.val" :label="item.name" :value="item.val">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="8" class="d-flex">
              <el-form-item label="工作年限" prop="nature" class="mini_input d-flex left_box">
                <el-select v-model="conditions.startWorkExp" filterable placeholder="请选择">
                  <el-option v-for="item in options.workExp" :key="item.val" :label="item.name" :value="item.val">
                  </el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="-" prop="nature" class="mini_input right_box d-flex">
                <el-select v-model="conditions.endWorkExp" filterable placeholder="请选择">
                  <el-option v-for="item in options.workExp" :key="item.val" :label="item.name" :value="item.val">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </div>

        <div class="d-flex">
          <el-row>
            <el-col :span="8">
              <el-form-item label="现从事职业" prop="trade" class="flex-1 wid_input">
                <el-cascader :options="options.jobCategory" :props="{value:'code',label:'name',children:'childVo'}"
                  v-model="conditions.jobCategory" style="width: 267px;"></el-cascader>
                <!-- <el-select
                                    v-model="conditions.jobCategory"
                                    filterable
                                    placeholder="现从事职业"
                                    style="width: 267px;"
                                >
                                    <el-option
                                        v-for="item in options.jobCategory"
                                        :key="item.code"
                                        :label="item.name"
                                        :value="item.code"
                                    ></el-option>
                                </el-select>-->
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="居住地" prop="trade" class="flex-1 wid_input">
                <el-select v-model="conditions.currentResidence" filterable placeholder="居住地">
                  <el-option v-for="item in options.workPlace" :key="item.val" :label="item.name" :value="item.val">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
        </div>
      </el-form>
      <el-form class="ruleForm-btn" ref="form" label-width="0">
        <div class="d-flex" style="margin-top: 17px; padding: 0 30px;">
          <div class="flex-1">
            <div class="d-flex" style="width: 267px;">
              <el-select v-model="conditions.jobId" placeholder="全部职位">
                <el-option v-for="item in job" :key="item.id" :label="item.name" :value="item.id"></el-option>
              </el-select>
              <el-select v-model="conditions.creationTime" placeholder="投递时间">
                <el-option v-for="(item,i) in creationTime" :key="i" :label="item" :value="i+1"></el-option>
              </el-select>
              <!-- <el-form-item prop="trade" class="flex-1 mr10">
                                 <el-select v-model="form.trade" placeholder="全部简历" style="width: 100%;">
                                     <el-option
                                             v-for="item in options.trade"
                                             :key="item.val"
                                             :label="item.name"
                                             :value="item.val"
                                     ></el-option>
                                 </el-select>
                             </el-form-item>
                             <el-form-item prop="time" class="flex-1">
                                 <el-date-picker
                                         v-model="form.time"
                                         type="date"
                                         placeholder="时间选择"
                                         value-format="yyyy-MM-dd"
                                         style="width: 100%;">
                                 </el-date-picker>
                            </el-form-item>-->
            </div>
          </div>
          <div class="flex-1 t-r">
            <el-row>
              <el-button type="primary" @click="getResumeList()">筛选简历</el-button>
              <el-button type="primary" plain @click="clearSearchConditions()">清空</el-button>
            </el-row>
          </div>
        </div>
      </el-form>
    </div>
    <div>
      <!--1.已投递，2.被查看，3.有意向，4.邀请面试，5.不合适-->
      <div class="table">
        <div style="margin-top: 20px; padding: 20px 0;">
          <el-button type="primary" @click="markIntention(3)">标记为有意向</el-button>
          <el-button type="primary" plain @click="markInappropriate">标记为不合适</el-button>
          <el-button type="primary" plain @click="markIntention(2)">标记为待定</el-button>
          <el-button type="primary" plain @click="invitedInterview">邀请面试</el-button>
          <el-button type="primary" plain @click="deleteResume">删除</el-button>
        </div>
        <el-table ref="multipleTable" v-loading="loading" element-loading-text="数据加载中" :data="tableData"
          tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange"
          :row-style="{height:'50px'}" :cell-style="{fontSize:'14px'}">
          <el-table-column type="selection" align="center" width="50"></el-table-column>
          <el-table-column prop="name" label="姓名" align="center" width="80">
            <template slot-scope="scope">
              <el-button
                @click="()=>{toResume(scope.row.id,scope.row.jobId,scope.row.userId,scope.row.deliverId,scope.row.status)}"
                type="text" style="padding:0;width:60px">{{scope.row.name}}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="职位名称" align="center" width="100">
            <template slot-scope="scope">
              <span>{{scope.row.categoryName}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="status" label="状态" align="center" width="100">
            <template slot-scope="scope">
              <span>{{resumeStatusMap[scope.row.status]}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="deliverTime" label="投递日期" align="center" width="120">
            <template slot-scope="scope">{{dateFormat(scope.row.deliverTime)}}</template>
          </el-table-column>
          <el-table-column prop="age" label="年龄" align="center" width="50" show-overflow-tooltip>
            <template slot-scope="scope">
              <span>{{(scope.row.age&&scope.row.age!==''&&String(scope.row.age).split(' ').length>=1)?String(scope.row.age).split(' ')[0]:scope.row.age}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="" label="工作年限" align="center" width="100">
            <template slot-scope="scope">
              <span>{{scope.row.workExpText?scope.row.workExpText:scope.row.workTime?scope.row.workTime:'无'}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="educationText" label="学历" align="center" width="80"></el-table-column>
          <el-table-column prop="currentResidenceText" label="居住地" align="center" width="150"></el-table-column>
          <el-table-column prop="schoolName" label="毕业院校" align="center" width="150" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="job" align="center" label="现职位" width="100" show-overflow-tooltip></el-table-column>
          <el-table-column prop="company" align="center" label="现公司" width="150" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="hopeJob" label="期望从事职位" width="150" align="center" show-overflow-tooltip>
          </el-table-column>
          <el-table-column label="期望工作地点" width="150" align="center" show-overflow-tooltip>
            <template slot-scope="scope">{{scope.row.workPlaceText}}</template>
          </el-table-column>
        </el-table>
        <!--<el-pagination
                        background
                        :total="pageInfo.total"
                        :page.sync="pageInfo.page"
                        :limit.sync="pageInfo.size"
                        @current-change="getList"
                        @prev-click="prev_click"
                        @next-click="next_click"
                        @size-change="size_change">
                </el-pagination>-->
        <div class="page">
          <el-pagination background @current-change="handleCurrentChange" :current-page="pageInfo.page"
            layout="prev, pager, next" :total="total"></el-pagination>
        </div>
      </div>
    </div>

    <el-dialog title="邀请面试" :visible.sync="invitedInterviewFormVisible" :before-close="invitedInterviewFormClose">
      <el-form :model="invitedInterviewForm.form" ref="invitedInterviewForm" :rules="invitedInterviewForm.rules"
        :label-width="formLabelWidth">
        <el-form-item label="邀请简历：">
          <span class="dialog-form-element">{{invitedInterviewForm.invitedInterviewNames}}</span>
        </el-form-item>
        <!-- <el-form-item label="面试职位：" prop="jobId" required>
                    <el-select
                        v-model="invitedInterviewForm.form.jobId"
                        placeholder="面试职位"
                        class="dialog-form-element"
                    >
                        <el-option
                            v-for="item in options.jobCategory"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                        ></el-option>
                    </el-select>
                </el-form-item>-->
        <el-form-item label="面试日期：" prop="interviewTime" required>
          <el-date-picker v-model="invitedInterviewForm.form.interviewTime" type="datetime" placeholder="时间选择"
            value-format="yyyy-MM-dd HH:mm:ss" class="dialog-form-element"></el-date-picker>
        </el-form-item>
        <el-form-item label="公司地址：" prop="inviteddress">
          <el-input v-model="invitedInterviewForm.form.inviteddress" placeholder="公司地址"></el-input>
        </el-form-item>
        <el-form-item label="邀请人：" prop="inviteContact">
          <el-input v-model="invitedInterviewForm.form.inviteContact" placeholder="邀请人"></el-input>
        </el-form-item>
        <el-form-item label="邀请人电话：" prop="invitePhone">
          <el-input v-model.trim="invitedInterviewForm.form.invitePhone" placeholder="邀请人电话"></el-input>
        </el-form-item>
        <el-form-item label="通知内容：" prop="notice">
          <el-input v-model="invitedInterviewForm.form.notice" type="textarea" placeholder="请输入通知内容" :rows="'8'"
            class="dialog-form-element"></el-input>
        </el-form-item>
        <el-form-item label="站内通知：">
          <el-checkbox :checked="checkd" class="dialog-form-element">站内信通知</el-checkbox>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="invitedInterviewFormClose">取 消</el-button>
        <el-button type="primary" @click="invitedInterviewSubmit('invitedInterviewForm')">提 交</el-button>
      </div>
    </el-dialog>

    <el-dialog title="标记为不合适" :visible.sync="markInappropriateFormVisible" class="refuseBox"
      :before-close="markInappropriateFormClose">
      <el-form :model="markInappropriateForm.form" ref="markInappropriateForm"
        :rules="markInappropriateForm.noticeRules">
        <el-form-item label="不合适原因：" label-width="110px" prop="notice">
          <el-input v-model="markInappropriateForm.form.notice" type="textarea" placeholder="请输入通知内容" :rows="'8'"
            class="dialog-form-element"></el-input>
        </el-form-item>
        <el-form-item label="发送站内信：" label-width="110px">
          <el-checkbox :checked="checkd" class="dialog-form-element">发送站内信</el-checkbox>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="markInappropriateFormClose">取 消</el-button>
        <el-button type="primary" @click="markInappropriateFormSubmit('markInappropriateForm')">提 交</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  queryResume, //简历查询
  // updateMsgIntention, //标为简历为有意向
  // updateMsgInappropriate, //标为简历不合适
  // updateMsgInvited, //邀请面试
  // updateStatusByUserId, //标记为待定
  // updateDeleteByUserId //删除投递记录
  deleteResume,
  getDict,
  getDictTrade,
  getDictJob,
  handleResume,
  getJobList
} from '../../../api/resume';
import QS from 'qs';
import { selectCompanyByUserId } from '../../../api/register'
import moment from 'moment';

export default {
  name: '',
  data () {
    let checkInterviewTime = (rule, value, callback) => {
      let today = new Date();
      let now =
        '' +
        today.getFullYear() +
        (today.getMonth() < 10 ? '0' + (today.getMonth() + 1) : today.getMonth() + 1) +
        (today.getDate() < 10 ? '0' + today.getDate() : today.getDate()) +
        (today.getHours() < 10 ? '0' + today.getHours() : today.getHours()) +
        (today.getMinutes() < 10 ? '0' + today.getMinutes() : today.getMinutes()) +
        (today.getSeconds() < 10 ? '0' + today.getSeconds() : today.getSeconds());
      console.log(now);
      let time = value
        .replace(/-/g, '')
        .replace(' ', '')
        .replace(/:/g, '');
      if (time < now) {
        callback(new Error('面试时间输入错误'));
      } else {
        callback();
      }
    };
    let checkAge = (rule, value, callback) => {
      if (this.conditions.startAge > value) {
        callback(new Error('年龄选择错误'));
      } else {
        callback();
      }
    };
    return {
      name: '',
      loading: true,
      tableData: [],
      multipleSelection: [],
      invitedInterviewFormVisible: false,
      markInappropriateFormVisible: false,
      workExpMap: {},
      job: [],
      creationTime: ['最近一周', '最近两周', '最近一月', '最近三月', '最近一年'],
      // 简历状态字典：<!--1.已投递，2.被查看，3.有意向，4.邀请面试，5.不合适-->
      resumeStatusMap: {
        1: '未查看',
        2: '被查看',
        3: '有意向',
        4: '邀请面试',
        5: '不合适'
      },
      formLabelWidth: '120px',
      options: {
        tradeCategory: [],
        workExp: [],
        education: [],
        jobCategory: [],
        workPlace: []
      },
      conditions: {
        company: undefined,
        trade: undefined,
        startAge: 16,
        endAge: 60,
        jobId: undefined,
        jobCategory: undefined,
        startWorkExp: undefined,
        endWorkExp: undefined,
        startEducation: undefined,
        endEducation: undefined,
        status: undefined,
        currentResidence: undefined,
        creationTime: undefined
      },
      rules: {
        endAge: [{ validator: checkAge }]
      },
      //邀请面试表单
      invitedInterviewForm: {
        invitedInterviewNames: '',
        rules: {
          jobId: [{ required: true, message: '请选择面试职位', trigger: 'blur' }],
          inviteddress: [{ required: true, message: '请输入公司地址', trigger: 'blur' }],
          inviteContact: [{ required: true, message: '请输入邀请人姓名', trigger: 'blur' }],
          invitePhone: [{ required: true, message: '请输入邀请人电话', trigger: 'blur' }, { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码', trigger: 'change' }],
          interviewTime: [{ required: true, message: '请选择面试日期', trigger: 'blur' }, { validator: checkInterviewTime }],
          notice: [{ required: true, message: '请输入通知内容', trigger: 'blur' }]
        },
        form: {
          jobId: '',
          interviewTime: '',
          inviteddress: '',
          inviteContact: '',
          invitePhone: null,
          notice: '',
          isSendNotification: true
        }
      },
      //标记为不合适表单
      markInappropriateForm: {
        noticeRules: {
          notice: [{ required: true, message: '请输入不合适原因', trigger: 'blur' }]
        },
        form: {
          notice: '',
          isSendNotification: true
        }
      },
      checkd: true,
      total: 20,
      pageInfo: {
        page: 1, //默认显示第1页
        size: 10 //默认一次显示10条数据
      }
    };
  },
  // filters: {
  //     getText(val, options) {
  //         if (val) {
  //             let ary = JSON.parse(val);
  //             let str = '';
  //             ary = ary.map(val => {
  //                 return options.workPlace.find(item => {
  //                     return item.val === val;
  //                 });
  //             });
  //             if (ary.length > 0) {
  //                 console.log(ary);
  //                 str = ary
  //                     .map(item => {
  //                         return item.name;
  //                     })
  //                     .join('/');
  //                 return str;
  //             }
  //         }
  //     }
  // },
  mounted () {
    selectCompanyByUserId().then(res => {
      if (res.success) {
        this.invitedInterviewForm.form.inviteddress = res.data.address;
        this.invitedInterviewForm.form.inviteContact = res.data.contact;
        this.invitedInterviewForm.form.invitePhone = res.data.contactPhone;
      }
    })
    let param = {};
    getJobList().then(data => {
      this.job = data.data || [];
    });
    getDict('work_exp,education,area').then(res => {
      this.options.workExp = res.data.work_exp;
      this.options.education = res.data.education;
      this.options.workPlace = res.data.area;
      this.options.workExp.forEach(item => {
        this.workExpMap[item.val] = item.name;
      });
      console.log(this.options);
    });
    getDictTrade().then(res => {
      console.log(res);

      this.options.tradeCategory = res.data;
    });
    getDictJob().then(res => {
      console.log(res);

      this.options.jobCategory = res.data;
      console.log(this.options);
    });
    //加载搜索条件
    queryResume(param).then(res => {
      console.log(res.data);

      this.loading = false;
      if (res.code !== 200) {
        this.$message({
          showClose: true,
          message: res.msg,
          type: 'error'
        });
        return;
      }
      // this.options.tradeCategory = res.data.tradeCategory;
      // this.options.workExp = res.data.workExp;
      // this.options.education = res.data.education;
      // this.options.jobCategory = res.data.jobCategory;
      // this.options.workPlace = res.data.workPlace;
      // //封装工作年限字典
      // this.options.workExp.forEach(item => {
      //     this.workExpMap[item.val] = item.name;
      // });
      this.tableData = res.data.records || [];
      this.total = res.data.total;
    });
  },
  methods: {
    //跳转到简历详情
    toResume (resumeId, jobId, userId, deliverId, status) {
      const { href } = this.$router.resolve({
        path: "/resumeManage",
        query: { resumeId, userId, jobId, deliverId, status }
      });
      window.open(href, '_blank');
    },
    //加载简历列表
    getResumeList () {
      let param = { ...this.conditions, ...this.pageInfo };
      param.status = param.status ? Number(param.status) : param.status;
      let startAge = param.startAge;
      //根据年龄确定出生日期范围
      param.startAge = moment()
        .subtract(Number(param.endAge), 'years')
        .format('YYYY');
      param.endAge = moment()
        .subtract(Number(startAge), 'years')
        .format('YYYY');
      console.log(param);

      param.trade = JSON.stringify(param.trade);
      param.jobCategory = JSON.stringify(param.jobCategory);
      //加载搜索条件
      queryResume(param).then(res => {
        if (res.code !== 200) {
          this.$message({
            showClose: true,
            message: res.msg,
            type: 'error'
          });
          this.loading = false;
          return;
        }
        this.tableData = res.data.records || [];
        this.total = res.data.total;
        this.loading = false;
      });
    },
    //清空搜索条件
    clearSearchConditions () {
      this.conditions = {
        company: undefined,
        trade: undefined,
        startAge: 16,
        endAge: 60,
        jobCategory: undefined,
        startWorkExp: undefined,
        endWorkExp: undefined,
        startEducation: undefined,
        endEducation: undefined,
        status: undefined,
        currentResidence: undefined
      };
      this.getResumeList();
    },
    //日期格式化
    dateFormat: function (dateStr) {
      if (dateStr === undefined) {
        return '';
      }
      return moment(dateStr).format('YYYY-MM-DD');
    },
    //选中站内信复选框
    // checkedNotice (val) {
    //   this.noticeChecked = val;
    // },

    //打开邀请面试表单
    invitedInterview () {
      // this.noticeChecked = true;
      if (this.multipleSelection.length < 1) {
        this.$message({
          showClose: true,
          message: '请至少选择一条简历信息',
          type: 'warning'
        });
      } else {
        this.invitedInterviewFormVisible = true;
        this.invitedInterviewForm.invitedInterviewNames = this.multipleSelection.map(item => item.name).join('、');
      }
    },
    //邀请面试表单提交
    invitedInterviewSubmit (formData) {
      this.$refs[formData].validate(valid => {
        if (valid) {
          let query = this.multipleSelection.map(item => {
            let obj = {};
            obj.deliverId = item.deliverId;
            obj.userId = item.userId;
            obj.jobId = item.jobId;
            obj.status = 4;
            obj.resumeId = item.id;
            obj.notice = this.invitedInterviewForm.form.notice;
            obj.interviewTime = this.invitedInterviewForm.form.interviewTime;
            obj.checkd = this.checkd;
            obj.inviteddress = this.invitedInterviewForm.form.inviteddress;
            obj.inviteContact = this.invitedInterviewForm.form.inviteContact;
            obj.invitePhone = this.invitedInterviewForm.form.invitePhone;
            return obj;
          });

          handleResume(query).then(data => {
            console.log(data);
            if (data.success) {
              this.$message({
                showClose: true,
                type: 'success',
                message: '邀请面试成功!'
              });
              //刷新加载简历列表
              this.getResumeList();
            } else {
              this.$message.error(`${data.msg}`);
            }
            this.invitedInterviewFormVisible = false;
            // this.$refs.invitedInterviewForm.resetFields()
          });

          // let params = [];
          // this.multipleSelection.forEach(item => {
          //     params.push({
          //         resumeId: item.id,
          //         userId: item.userId,
          //         deliverId: item.resumeDeliverId,
          //         jobId: this.invitedInterviewForm.form.jobId,
          //         interviewTime: this.invitedInterviewForm.form.interviewTime,
          //         notice: this.invitedInterviewForm.form.notice
          //     });
          // });
          // updateMsgInvited(params).then(res => {
          //     if (res.code === 200) {
          //         this.$message({
          //             showClose: true,
          //             type: 'success',
          //             message: '邀请面试成功!'
          //         });
          //         //刷新加载简历列表
          //         this.getResumeList();
          //     } else {
          //         this.$message({
          //             showClose: true,
          //             type: 'error',
          //             message: '邀请面试失败!'
          //         });
          //     }
        }
      });
    },
    markInappropriateFormClose () {
      console.log(1);

      this.$refs.markInappropriateForm.resetFields()
      this.markInappropriateFormVisible = false;
    },
    //打开标记为不合适表单
    markInappropriate () {
      // this.noticeChecked = true;

      if (this.multipleSelection.length < 1) {
        this.$message({
          showClose: true,
          message: '请至少选择一条简历信息',
          type: 'warning'
        });
      } else {
        this.markInappropriateFormVisible = true;
      }
    },
    invitedInterviewFormClose () {
      // this.$refs.invitedInterviewForm.resetFields()
      this.invitedInterviewFormVisible = false;
    },
    //标记为不合适表单提交
    markInappropriateFormSubmit (formData) {
      this.$refs[formData].validate(valid => {
        if (valid) {
          let query = this.multipleSelection.map(item => {
            let obj = {};
            obj.deliverId = item.deliverId;
            obj.userId = item.userId;
            obj.jobId = item.jobId;
            obj.status = 5;
            obj.resumeId = item.id;
            obj.notice = this.markInappropriateForm.form.notice;
            obj.interviewTime = this.markInappropriateForm.form.interviewTime;
            obj.checkd = this.checkd;
            return obj;
          });

          handleResume(query).then(data => {
            console.log(data);
            if (data.success) {
              this.$message({
                showClose: true,
                type: 'success',
                message: '标记成功!'
              });
              //刷新加载简历列表
              this.getResumeList();
            } else {
              this.$message.error(`${data.msg}`);
            }
            this.$refs.markInappropriateForm.resetFields()
            this.markInappropriateFormVisible = false;
          });
          // let params = [];
          // this.multipleSelection.forEach(item => {
          //     params.push({
          //         resumeId: item.id,
          //         userId: item.userId,
          //         deliverId: item.resumeDeliverId,
          //         notice: this.invitedInterviewForm.form.notice
          //     });
          // });
          // updateMsgInappropriate(params).then(res => {
          //     if (res.code === 200) {
          //         this.$message({
          //             showClose: true,
          //             type: 'success',
          //             message: '标记为不合适保存成功!'
          //         });
          //         //刷新加载简历列表
          //         this.getResumeList();
          //     } else {
          //         this.$message({
          //             showClose: true,
          //             type: 'error',
          //             message: '标记为不合适保存失败!'
          //         });
          //     }
          //     this.markInappropriateFormVisible = false;
          // });
        }
      });
    },
    // 删除简历
    deleteResume () {
      if (this.multipleSelection.length < 1) {
        this.$message({
          showClose: true,
          message: '请至少选择一条简历信息',
          type: 'warning'
        });
        return
      }
      this.$confirm('您要删除简历，删除后不可恢复，是否确定操作？', '信息提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        callback: action => {
          if (action === 'confirm') {
            let query = this.multipleSelection.map(item => {
              return item.deliverId;
            });
            // let formData = new FormData();
            // formData.append('ids', JSON.stringify(query))'1,2,32,2'
            deleteResume(query).then(res => {
              if (res.success) {
                this.$message.success('删除成功')
                this.getResumeList();
              } else {
                this.$message.error(`${res.msg}`)
              }
            })
          }
        }
      })
    },
    //标记为有意向
    markIntention (status) {
      if (this.multipleSelection.length < 1) {
        this.$message({
          showClose: true,
          message: '请至少选择一条简历信息',
          type: 'warning'
        });
        return;
      }
      // if (status === 6) {
      //   this.$confirm('您要删除简历，删除后不可恢复，是否确定操作？', '信息提示', {
      //     confirmButtonText: '确定',
      //     cancelButtonText: '取消',
      //     type: 'warning',
      //     callback: action => {
      //       if (action === 'confirm') {
      //         let query = this.multipleSelection.map(item => {
      //           let obj = {};
      //           obj.deliverId = item.deliverId;
      //           obj.userId = item.userId;
      //           obj.jobId = item.jobId;
      //           obj.status = 6;
      //           obj.resumeId = item.id;
      //           obj.notice = '';
      //           obj.interviewTime = '';
      //           obj.checkd = false;
      //           return obj;
      //         });
      //         console.log(query);
      //         handleResume(query).then(data => {
      //           console.log(data);
      //           if (data.success) {
      //             this.$message({
      //               showClose: true,
      //               type: 'success',
      //               message: '删除成功!'
      //             });
      //             // 刷新加载简历列表;
      //             this.getResumeList();
      //           } else {
      //             this.$message.error(`${data.msg}`);
      //           }
      //         });
      //       }
      //     }
      //   });
      // } else {
      let query = this.multipleSelection.map(item => {
        let obj = {};
        obj.deliverId = item.deliverId;
        obj.userId = item.userId;
        obj.jobId = item.jobId;
        obj.status = status;
        obj.resumeId = item.id;
        obj.notice = '';
        obj.interviewTime = '';
        obj.checkd = status === 2 ? false : true;
        return obj;
      });
      console.log(query);

      handleResume(query).then(data => {
        console.log(data);
        if (data.success) {
          this.$message({
            showClose: true,
            type: 'success',
            message: '标记成功!'
          });
          this.getResumeList();
        } else {
          this.$message.error(`${data.msg}`);
        }
      });
      // }

      // if (this.multipleSelection.length < 1) {
      //     this.$message({
      //         showClose: true,
      //         message: '请至少选择一条简历信息',
      //         type: 'warning'
      //     });
      //     return;
      // }
      // let params = [];
      // this.multipleSelection.forEach(item => {
      //     params.push({
      //         resumeId: item.id,
      //         userId: item.userId,
      //         deliverId: item.resumeDeliverId
      //     });
      // });
      // updateMsgIntention(params).then(res => {
      //     if (res.code === 200) {
      //         this.$message({
      //             showClose: true,
      //             type: 'success',
      //             message: '标记为有意向保存成功!'
      //         });
      //         //刷新加载简历列表
      //         this.getResumeList();
      //     } else {
      //         this.$message({
      //             showClose: true,
      //             type: 'error',
      //             message: '标记为有意向保存失败!'
      //         });
      //     }
      // });
    },
    //标记为待定
    // markToBeDetermined() {
    //     if (this.multipleSelection.length < 1) {
    //         this.$message({
    //             showClose: true,
    //             message: '请至少选择一条简历信息',
    //             type: 'warning'
    //         });
    //         return;
    //     }
    //     let ids = this.multipleSelection.map(item => {
    //         return item.id;
    //     });
    //     let params = QS.stringify({ id: ids }, { indices: false });
    //     updateStatusByUserId(params).then(res => {
    //         if (res.code === 200) {
    //             this.$message({
    //                 showClose: true,
    //                 type: 'success',
    //                 message: '标记为待定保存成功!'
    //             });
    //             //刷新加载简历列表
    //             this.getResumeList();
    //         } else {
    //             this.$message({
    //                 showClose: true,
    //                 type: 'error',
    //                 message: '标记为待定保存失败!'
    //             });
    //         }
    //     });
    // },
    // //删除简历投递记录
    // deleteResume() {
    //     if (this.multipleSelection.length < 1) {
    //         this.$message({
    //             showClose: true,
    //             message: '请至少选择一条简历信息',
    //             type: 'warning'
    //         });
    //         return;
    //     }
    //     this.$confirm('您要删除简历，删除后不可恢复，是否确定操作?', '信息提醒', {
    //         confirmButtonText: '确定',
    //         cancelButtonText: '取消',
    //         type: 'warning'
    //     }).then(() => {
    //         let ids = this.multipleSelection.map(item => {
    //             return item.id;
    //         });
    //         let params = QS.stringify({ id: ids }, { indices: false });
    //         updateStatusByUserId(params).then(res => {
    //             if (res.code === 200) {
    //                 this.$message({
    //                     showClose: true,
    //                     type: 'success',
    //                     message: '简历删除成功!'
    //                 });
    //                 //刷新加载简历列表
    //                 this.getResumeList();
    //             } else {
    //                 this.$message({
    //                     showClose: true,
    //                     type: 'error',
    //                     message: '简历删除失败!'
    //                 });
    //             }
    //         });
    //     });
    // },
    handleCurrentChange (val) {
      this.pageInfo.page = val;
      console.log(this.pageInfo);

      this.getResumeList();
      console.log(`当前页: ${val}`);
    },
    //表格复选框选中事件
    handleSelectionChange (val) {
      console.log(val);
      this.multipleSelection = val;
    }
  }
};
</script>

<style scoped>
.resume_manage {
    margin-top: 10px;
    width: 1200px;
}

.info {
    width: 1200px;
    background: #fff;
    padding: 17px 0;
    margin: 0 auto;
}

.table {
    width: 1200px;
    background: #fff;
    margin: 5px auto 30px;
    padding: 0 30px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    -ms-box-sizing: border-box;
    -o-box-sizing: border-box;
}

.d-flex {
    display: flex;
    flex-direction: row;
}

.flex-1 {
    flex: 1;
}
.el-row {
    width: 100%;
}

.t-r {
    text-align: right;
}
.t-r .el-button {
    width: 120px;
    height: 34px;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    opacity: 1;
}
.dialog-form-element {
    line-height: 40px;
}

.wid_input /deep/ .el-form-item__label {
    width: 90px;
}
.wid_input /deep/ .el-input {
    width: 240px;
    height: 40px;
}
.wid_input /deep/ .el-input__inner {
    width: 240px;
    height: 40px;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(232, 232, 232, 1);
    opacity: 1;
}
.mini_input /deep/ .el-input {
    width: 106px;
    height: 40px;
}
.mini_input /deep/ .el-input__inner {
    opacity: 1;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(232, 232, 232, 1);
    width: 106px;
    height: 40px;
}
.right_box {
    margin-left: 10px;
}
.right_box /deep/ .el-form-item__label {
    width: 15px;
}
.left_box /deep/ .el-form-item__label {
    width: 90px;
}
.table .el-button {
    width: 94px;
    height: 24px;
    line-height: 0;
    padding: 0;
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 400;
    opacity: 1;
}
.resume_manage /deep/ .el-dialog {
    width: 634px;
    background: rgba(255, 255, 255, 1);
    opacity: 1;
}
.el-dialog .el-form-item /deep/ .el-form-item__label {
    /* width: 94px !important; */
    height: 40px;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 40px;
    color: rgba(85, 85, 85, 1);
    opacity: 1;
}
.el-dialog .el-form-item /deep/ .el-textarea {
    display: inline-block;
    width: 466px;
    height: 191px;
}
.el-dialog /deep/ .el-textarea__inner {
    display: inline-block;
    width: 497px;
    height: 191px;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(232, 232, 232, 1);
    opacity: 1;
}
.el-dialog .el-form-item /deep/ .el-input {
    display: inline-block;
    width: 240px;
    height: 40px;
}
.el-dialog .el-form-item /deep/ .el-input__inner {
    width: 240px;
    height: 40px;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(232, 232, 232, 1);
    opacity: 1;
}
.el-dialog .el-button {
    width: 120px;
    height: 34px;
    opacity: 1;
}

.refuseBox .el-form-item /deep/ .el-form-item__label {
    width: 110px !important;
    height: 40px;
    font-size: 14px;
    font-family: PingFang SC;
    font-weight: 400;
    line-height: 40px;
    color: rgba(85, 85, 85, 1);
    opacity: 1;
}
.refuseBox .el-dialog /deep/ .el-textarea__inner {
    display: inline-block;
    width: 428px;
    height: 191px;
    background: rgba(255, 255, 255, 1);
    border: 1px solid rgba(232, 232, 232, 1);
    opacity: 1;
}
.refuseBox .el-dialog .el-form-item /deep/ .el-textarea {
    display: inline-block;
    width: 428px;
    height: 191px;
}
.ruleForm-btn /deep/ .el-input__inner {
    background: #fff;
    border: none !important;
    width: 100px;
}
.ruleForm-btn /deep/ .el-input {
    background: #fff;
    border: none;
}
.page {
    line-height: 50px;
}
.page .el-pagination {
    width: 100%;
    text-align: center;
    padding-top: 20px;
}
</style>